package main

import "fmt"

type Student struct {
	name    string
	age     int
	married bool
	sex     int8
}

func main() {
	var s1 = Student{"Steven", 35, true, 1}
	var s2 = Student{"Sunny", 20, false, 0}
	// 将 s1 的内存地址赋值给 Student 指针变量 a
	var a *Student = &s1
	// 将 s2 的内存地址赋值给 Student 指针变量 b
	var b *Student = &s2

	fmt.Printf("s1 类型为 %T, 值为 %v \n", s1, s1)
	fmt.Printf("s2 类型为 %T, 值为 %v \n", s2, s2)
	fmt.Printf("a 类型为 %T, 值为 %v \n", a, a)
	fmt.Printf("b 类型为 %T, 值为 %v \n", b, b)
	fmt.Printf("*a 类型为 %T, 值为 %v \n", *a, *a)
	fmt.Printf("*b 类型为 %T, 值为 %v \n", *b, *b)

	fmt.Println(s1.name, s1.age, s1.married, s1.sex)
	fmt.Println(a.name, a.age, a.married, a.sex)
	fmt.Println(s2.name, s2.age, s2.married, s2.sex)
	fmt.Println(b.name, b.age, b.married, b.sex)

	fmt.Println((*a).name, (*a).age, (*a).married, (*a).sex)
	fmt.Println((*b).name, (*b).age, (*b).married, (*b).sex)

	fmt.Printf("&a 类型为 %T, 值为 %v \n", &a, &a)
	fmt.Printf("&b 类型为 %T, 值为 %v \n", &b, &b)

	fmt.Println(&a.name, &a.age, &a.married, &a.sex)
	fmt.Println(&b.name, &b.age, &b.married, &b.sex)
}
